package com.wxzl.community.common.data


import android.annotation.SuppressLint
import android.os.Parcelable
import androidx.annotation.Keep
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize

@SuppressLint("ParcelCreator")
@Parcelize
@Keep
data class UserInfo(
        @SerializedName(value = "accessToken",alternate = ["access_token"])
        var accessToken: String,
        @SerializedName("birthday")
        var birthday: String?,
        @SerializedName("buildingId")
        var buildingId: Long?,
        @SerializedName("carNo")
        var carNo: String?,
        @SerializedName("checkStatus")
        var checkStatus: Int,
        @SerializedName("checkStatusStr")
        var checkStatusStr: String?,
        @SerializedName("communityBuildingName")
        var communityBuildingName: String?,
        @SerializedName("communityId")
        var communityId: Long?,
        @SerializedName("communityName")
        var communityName: String?,
        @SerializedName("completion")
        var completion: String?,
        @SerializedName("education")
        var education: String?,
        @SerializedName("email")
        var email: String?,
        @SerializedName("hobby")
        var hobby: String?,
        @SerializedName("houseId")
        var houseId: Long?,
        @SerializedName("id")
        var id: String,
        @SerializedName("img")
        var img: String?,
        @SerializedName("imgFace")
        var imgFace: String?,
        @SerializedName("lastLoginAt")
        var lastLoginAt: String?,
        @SerializedName("members")
        var members: Int?,
        @SerializedName("nickname")
        var nickname: String?,
        @SerializedName("phone")
        var phone: String ,
        @SerializedName("position")
        var position: String?,
        @SerializedName(value = "refreshToken",alternate = ["refresh_token"])
        var refreshToken: String,
        @SerializedName("sex")
        var sex: Int?,
        @SerializedName("sexStr")
        var sexStr: String?,
        @SerializedName("type")
        var type: Int ,
        @SerializedName("realname")
        var realname: String?,
        @SerializedName("idCard")
        var idCard: String?,
        @SerializedName("gateNumber")
        var gateNumber: String?,
        @SerializedName("phoneHidden")
        var phoneHidden: String?,
        @SerializedName("idCardHidden")
        var idCardHidden: String?,
        @SerializedName("userPwd")
        var userPwd: String?,
        @SerializedName("imgCardUp")
        var imgCardUp: String?,
        @SerializedName("imgCardDown")
        var imgCardDown: String?,
        @SerializedName("coin")
        var coin: String?,
        ) : Parcelable {

    //    类型：0游客/未定义，1业主，2业主成员，3租客，4租客成员
    fun getTyepStr(): String {
        when (type) {
            1 -> {
                return "业主"
            }
            2 -> {
                return "家人"
            }
            3 -> {
                return "租客"
            }
            4 -> {
                return "朋友"
            }
            else -> {
                return "游客"
            }
        }
    }

    /**
     * 是否是业主
     */
    fun isOwner() = type == 1

    /**
     * 是否是租客
     */
    fun isTenant() = type == 3

    /**
     * 是否已添加房产
     */
    fun hasHouse(): Boolean{
        return buildingId != null && houseId != null
    }

    /**
     * 是否选择小区
     */
    fun isSelectCommunity(): Boolean{
        return communityId != null
    }

    fun getStatus(): String {

        if (checkStatusStr.isNullOrEmpty()){
            return "未认证"
        }else {
            return  checkStatusStr!!
        }
     }

    /**
     * 是否可编辑,已认证用户不能编辑我的资料中的必填信息
     */
    fun isEditable(): Boolean{
        return checkStatus != 1
    }

    /**
     * 是否已认证
     */
    fun isCertified(): Boolean{
        return checkStatus == 1
    }

}